#include "lclog.h"
//#include "HookVb.h"
char g_szLogFilePath[512] = {0};
void initLogPath(char * pPathDir,char * pFileName)
{
	sprintf(g_szLogFilePath,"%s\\%s",pPathDir,pFileName);
	return ;
}
HANDLE RealCreateMutex(
__in_opt LPSECURITY_ATTRIBUTES lpMutexAttributes,
__in     BOOL bInitialOwner,
__in_opt LPCSTR lpName)
{
	//HANDLE hMutex; 
	//UNICODE_STRING DestinationString;
	//OBJECT_ATTRIBUTES attr;
	//RtlInitUnicodeString(&DestinationString,L"\\Sessions\\1\\Windows\\log");
	//InitializeObjectAttributes(&attr,&DestinationString/*name*/,0X08/*attr*/,NULL/*root*/,NULL/*s*/);
	//NtCreateMutant(&hMutex,
	//	 default security attributes
	//	NULL, &attr,                     // initially not owned
	//	0x1F0001);
	return 0;
}
void log(char * data)
{
	HANDLE hMutex; 
	//////NtCreateMutant(&hMutex,NULL,
	//////	// default security attributes
	//////	NULL,                      // initially not owned
	//////	0x1F0001);
	hMutex = RealCreateMutex( 
		NULL,                       // default security attributes
		FALSE,                      // initially not owned
		"log");
	::WaitForSingleObject(hMutex,INFINITE);
	FILE * file = fopen(g_szLogFilePath,"a");
	if(file)
	{
		fprintf(file,"%s",data);
		fclose(file);
	}
	::ReleaseMutex(hMutex);
}
void mylog(char * format,...)
{
	va_list arg_ptr;

	va_start(arg_ptr, format);
	char szData[100000] = {0};
	vsprintf(szData, format, arg_ptr);
	log(szData);
	va_end(arg_ptr);
}

